package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.project.RCSaleCommissionPayment;
import com.shrct.businessprocess.project.RCSaleCommissionPayment4CalcSettlementYear;
import com.shrct.businessprocess.project.RCSaleCommissionPayment4SettlementYear;
import com.shrct.businessprocess.project.RCSaleCommissionYearPayment;
import com.shrct.businessprocess.project.RCSalePayStrategyDAO;
import com.shrct.businessprocess.project.RCSalesAssignment;
import com.shrct.businessprocess.project.RCSalesCommissionYearConfig;
import com.shrct.businessprocess.project.impl.RCSaleCommissionPayment4CalcSettlementYearImpl;
import com.shrct.businessprocess.project.impl.RCSaleCommissionPayment4SettlementYearImpl;
import com.shrct.businessprocess.project.impl.RCSaleCommissionYearPaymentImpl;
import com.shrct.businessprocess.project.proxy.RCSaleCommissionPaymentProxy;
import edu.fudan.mylang.common.NumberExtensions;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.DoubleExtensions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.Functions.Function2;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;
import org.springframework.beans.factory.BeanFactory;

@Entity
@DiscriminatorValue("RCSALECOMMISSIONPAYMENT_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcsalecommissionpayment")
public class RCSaleCommissionPaymentImpl extends BaseModelObject implements RCSaleCommissionPayment {
  public RCSaleCommissionPaymentImpl() {
    super();
  }
  
  public RCSaleCommissionPaymentImpl(final RCSaleCommissionYearPayment yearPayment) {
    super();
    this.yearPayment = yearPayment;
  }
  
  @JoinColumn(name = "yearPayment_id")
  @ManyToOne(targetEntity = RCSaleCommissionYearPaymentImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCSaleCommissionYearPayment yearPayment;
  
  public RCSaleCommissionYearPayment getYearPayment() {
    return this.yearPayment;
  }
  
  public RCSaleCommissionPayment setYearPayment(final RCSaleCommissionYearPayment yearPayment) {
    this.yearPayment = yearPayment;
    return this;			
    
  }
  
  private Date date;
  
  public Date getDate() {
    return this.date;
  }
  
  public RCSaleCommissionPayment setDate(final Date date) {
    this.date = date;
    return this;			
    
  }
  
  @OneToMany(targetEntity = RCSaleCommissionPayment4SettlementYearImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE }, mappedBy = "payment")
  private Collection<RCSaleCommissionPayment4SettlementYear> settlementYearPayments = new java.util.ArrayList<com.shrct.businessprocess.project.RCSaleCommissionPayment4SettlementYear>();;
  
  public Collection<RCSaleCommissionPayment4SettlementYear> getSettlementYearPayments() {
    return this.settlementYearPayments;
  }
  
  public RCSaleCommissionPayment removeAllSettlementYearPayments() {
    for(RCSaleCommissionPayment4SettlementYear obj : this.settlementYearPayments){
    	getObjectFactory().delete(obj);
    }
    this.settlementYearPayments.clear();
    return this;	
    
  }
  
  public RCSaleCommissionPayment removeFromSettlementYearPayments(final RCSaleCommissionPayment4SettlementYear rCSaleCommissionPayment4SettlementYear) {
    this.settlementYearPayments.remove(rCSaleCommissionPayment4SettlementYear);
    getObjectFactory().delete(rCSaleCommissionPayment4SettlementYear);
    return this;
    
  }
  
  public Double getCommissionAmount() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _commissionAmount = it.getCommissionAmount();
          return _commissionAmount;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  public Double getOverflowCommissionAmount() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _overflowCommissionAmount = it.getOverflowCommissionAmount();
          return _overflowCommissionAmount;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  public Double getTeamPrizeAmount() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _teamPrizeAmount = it.getTeamPrizeAmount();
          return _teamPrizeAmount;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  public Double getCom1() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _com1 = it.getCom1();
          return _com1;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  public Double getCom2() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _com2 = it.getCom2();
          return _com2;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  public Double getTax() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _tax = it.getTax();
          return _tax;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  public Double getNetCom1() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _netCom1 = it.getNetCom1();
          return _netCom1;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  /**
   * 应付佣金
   */
  public Double getTotalSettlementAmount() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _totalSettlementAmount = it.getTotalSettlementAmount();
          return _totalSettlementAmount;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  /**
   * 本期佣金
   */
  public Double getTotalAmount() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _totalAmount = it.getTotalAmount();
          return _totalAmount;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  /**
   * 预计佣金
   */
  public Double getTotalAmountTarget() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _totalAmountTarget = it.getTotalAmountTarget();
          return _totalAmountTarget;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  /**
   * 已付佣金
   */
  public Double getTotalPaidAmount() {
    final Function1<RCSaleCommissionPayment4SettlementYear,Double> _function = new Function1<RCSaleCommissionPayment4SettlementYear,Double>() {
        public Double apply(final RCSaleCommissionPayment4SettlementYear it) {
          Double _totalPaidAmount = it.getTotalPaidAmount();
          return _totalPaidAmount;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment4SettlementYear, Double>map(this.settlementYearPayments, _function);
    final Function2<Double,Double,Double> _function_1 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_1);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  /**
   * 以Std开头的用于自动计算
   */
  public Double getStdCom2Amount() {
    double _xblockexpression = (double) 0;
    {
      BeanFactory _beanFactory = this.getBeanFactory();
      RCSalePayStrategyDAO _bean = _beanFactory.<RCSalePayStrategyDAO>getBean(RCSalePayStrategyDAO.class);
      Double _totalUptoTihsTimeAmount = this.getTotalUptoTihsTimeAmount();
      Double _comparableIncomeAmount = this.yearPayment.getComparableIncomeAmount();
      final Double part1 = _bean.calcCom2Amount(_totalUptoTihsTimeAmount, _comparableIncomeAmount);
      final Double part2 = this.getStdPaidCom2Amount();
      double _minus = DoubleExtensions.operator_minus(part1, part2);
      _xblockexpression = (_minus);
    }
    return Double.valueOf(_xblockexpression);
  }
  
  public Double getStdCom1Amount() {
    Double _totalAmount = this.getTotalAmount();
    Double _stdCom2Amount = this.getStdCom2Amount();
    double _minus = DoubleExtensions.operator_minus(_totalAmount, _stdCom2Amount);
    return Double.valueOf(_minus);
  }
  
  public Double getStdTax() {
    Double _stdCom1Amount = this.getStdCom1Amount();
    Double _preDiscount = this.yearPayment.getPreDiscount();
    Double _nullsafe = NumberExtensions.nullsafe(_preDiscount);
    double _multiply = DoubleExtensions.operator_multiply(_stdCom1Amount, _nullsafe);
    Double _ownedAmount = this.yearPayment.getOwnedAmount();
    Double _nullsafe_1 = NumberExtensions.nullsafe(_ownedAmount);
    double _minus = (_multiply - (_nullsafe_1).doubleValue());
    return Double.valueOf(_minus);
  }
  
  public Double getStdNetCom1Amount() {
    Double _stdCom1Amount = this.getStdCom1Amount();
    Double _stdTax = this.getStdTax();
    double _minus = DoubleExtensions.operator_minus(_stdCom1Amount, _stdTax);
    return Double.valueOf(_minus);
  }
  
  /**
   * 本年支付（含本次）
   */
  public Double getTotalUptoTihsTimeAmount() {
    Collection<RCSaleCommissionPayment> _payments = this.yearPayment.getPayments();
    final Function1<RCSaleCommissionPayment,Boolean> _function = new Function1<RCSaleCommissionPayment,Boolean>() {
        public Boolean apply(final RCSaleCommissionPayment it) {
          Date _date = it.getDate();
          boolean _lessEqualsThan = (_date.compareTo(RCSaleCommissionPaymentImpl.this.date) <= 0);
          return Boolean.valueOf(_lessEqualsThan);
        }
      };
    Iterable<RCSaleCommissionPayment> _filter = IterableExtensions.<RCSaleCommissionPayment>filter(_payments, _function);
    final Function1<RCSaleCommissionPayment,Double> _function_1 = new Function1<RCSaleCommissionPayment,Double>() {
        public Double apply(final RCSaleCommissionPayment it) {
          Double _totalAmount = it.getTotalAmount();
          return _totalAmount;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment, Double>map(_filter, _function_1);
    final Function2<Double,Double,Double> _function_2 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_2);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  /**
   * 本次支付之前所有的com2支付金额之和
   */
  private Double getStdPaidCom2Amount() {
    Collection<RCSaleCommissionPayment> _payments = this.yearPayment.getPayments();
    final Function1<RCSaleCommissionPayment,Boolean> _function = new Function1<RCSaleCommissionPayment,Boolean>() {
        public Boolean apply(final RCSaleCommissionPayment it) {
          Date _date = it.getDate();
          boolean _lessThan = (_date.compareTo(RCSaleCommissionPaymentImpl.this.date) < 0);
          return Boolean.valueOf(_lessThan);
        }
      };
    Iterable<RCSaleCommissionPayment> _filter = IterableExtensions.<RCSaleCommissionPayment>filter(_payments, _function);
    final Function1<RCSaleCommissionPayment,Double> _function_1 = new Function1<RCSaleCommissionPayment,Double>() {
        public Double apply(final RCSaleCommissionPayment it) {
          Double _com2 = it.getCom2();
          return _com2;
        }
      };
    Iterable<Double> _map = IterableExtensions.<RCSaleCommissionPayment, Double>map(_filter, _function_1);
    final Function2<Double,Double,Double> _function_2 = new Function2<Double,Double,Double>() {
        public Double apply(final Double d1, final Double d2) {
          double _plus = DoubleExtensions.operator_plus(d1, d2);
          return Double.valueOf(_plus);
        }
      };
    Double _reduce = IterableExtensions.<Double>reduce(_map, _function_2);
    Double _nullsafe = NumberExtensions.nullsafe(_reduce);
    return _nullsafe;
  }
  
  public void updateDerivedValues() {
    final Double stdCom2 = this.getStdCom2Amount();
    final Double stdTax = this.getStdTax();
    final Double totalAmount = this.getTotalAmount();
    boolean _notEquals = ((totalAmount).doubleValue() != 0d);
    if (_notEquals) {
      final Procedure1<RCSaleCommissionPayment4SettlementYear> _function = new Procedure1<RCSaleCommissionPayment4SettlementYear>() {
          public void apply(final RCSaleCommissionPayment4SettlementYear it) {
            Double _totalAmount = it.getTotalAmount();
            final double rate = DoubleExtensions.operator_divide(_totalAmount, totalAmount);
            double _multiply = ((stdCom2).doubleValue() * rate);
            it.setCom2(Double.valueOf(_multiply));
            double _multiply_1 = ((stdTax).doubleValue() * rate);
            it.setTax(Double.valueOf(_multiply_1));
          }
        };
      IterableExtensions.<RCSaleCommissionPayment4SettlementYear>forEach(this.settlementYearPayments, _function);
    }
  }
  
  public void initializePayments4SettlementYear() {
    RCSalesAssignment _saler = this.yearPayment.getSaler();
    Collection<RCSalesCommissionYearConfig> _commissionConfigs = _saler.getCommissionConfigs();
    final Procedure1<RCSalesCommissionYearConfig> _function = new Procedure1<RCSalesCommissionYearConfig>() {
        public void apply(final RCSalesCommissionYearConfig contract) {RCSaleCommissionPayment4CalcSettlementYear rCSaleCommissionPayment4CalcSettlementYear=RCSaleCommissionPayment4CalcSettlementYearImpl.create(RCSaleCommissionPaymentImpl.this,getObjectFactory());
          final Procedure1<RCSaleCommissionPayment4CalcSettlementYear> _function = new Procedure1<RCSaleCommissionPayment4CalcSettlementYear>() {
              public void apply(final RCSaleCommissionPayment4CalcSettlementYear it) {
                it.setContract(contract);
                Double _totalCommission = contract.getTotalCommission();
                Double _nullsafe = NumberExtensions.nullsafe(_totalCommission);
                Double _totalCommissionAmountPaid = contract.getTotalCommissionAmountPaid();
                Double _nullsafe_1 = NumberExtensions.nullsafe(_totalCommissionAmountPaid);
                double _minus = DoubleExtensions.operator_minus(_nullsafe, _nullsafe_1);
                it.setCommissionAmount(Double.valueOf(_minus));
                Double _totalOverflowCommissionAmount = contract.getTotalOverflowCommissionAmount();
                Double _nullsafe_2 = NumberExtensions.nullsafe(_totalOverflowCommissionAmount);
                Double _totalOverflowCommissionAmountPaid = contract.getTotalOverflowCommissionAmountPaid();
                Double _nullsafe_3 = NumberExtensions.nullsafe(_totalOverflowCommissionAmountPaid);
                double _minus_1 = DoubleExtensions.operator_minus(_nullsafe_2, _nullsafe_3);
                it.setOverflowCommissionAmount(Double.valueOf(_minus_1));
                Double _totalTeamPrizeAmount = contract.getTotalTeamPrizeAmount();
                Double _nullsafe_4 = NumberExtensions.nullsafe(_totalTeamPrizeAmount);
                Double _totalTeamPrizeAmountPaid = contract.getTotalTeamPrizeAmountPaid();
                Double _nullsafe_5 = NumberExtensions.nullsafe(_totalTeamPrizeAmountPaid);
                double _minus_2 = DoubleExtensions.operator_minus(_nullsafe_4, _nullsafe_5);
                it.setTeamPrizeAmount(Double.valueOf(_minus_2));
                RCSaleCommissionPaymentImpl.this.settlementYearPayments.add(it);
              }
            };
          ObjectExtensions.<RCSaleCommissionPayment4CalcSettlementYear>operator_doubleArrow(rCSaleCommissionPayment4CalcSettlementYear, _function);
        }
      };
    IterableExtensions.<RCSalesCommissionYearConfig>forEach(_commissionConfigs, _function);
    this.updateDerivedValues();
  }
  
  public static RCSaleCommissionPayment create(final RCSaleCommissionYearPayment yearPayment, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.project.RCSaleCommissionPayment rCSaleCommissionPayment = new com.shrct.businessprocess.project.impl.RCSaleCommissionPaymentImpl(
    	yearPayment
    );
    objectFactory.create(rCSaleCommissionPayment);
    return rCSaleCommissionPayment;			
    
  }
  
  public static RCSaleCommissionPayment createRCSaleCommissionPaymentImpl(final RCSaleCommissionYearPayment yearPayment, final IObjectFactory objectFactory, final Procedure1<RCSaleCommissionPayment> init) {
    com.shrct.businessprocess.project.RCSaleCommissionPayment rCSaleCommissionPayment = new com.shrct.businessprocess.project.impl.RCSaleCommissionPaymentImpl(
    	yearPayment
    );
    objectFactory.create(rCSaleCommissionPayment);
    init.apply(rCSaleCommissionPayment);
    
    return rCSaleCommissionPayment;			
    
  }
  
  public RCSaleCommissionPaymentProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCSaleCommissionPaymentProxy proxy = new com.shrct.businessprocess.project.proxy.RCSaleCommissionPaymentProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
